package com.zycfc.zsf.boot.mybatis.generator.codegen.model;

import java.util.*;
import com.zycfc.zsf.boot.util.text.*;
import java.util.concurrent.*;

public class ColumnModel
{
    private String columnName;
    private String humpColumnName;
    private String comment;
    private String colType;
    private String colDbType;
    private boolean isPK;
    private long length;
    private int precision;
    private int scale;
    private int autoGen;
    private boolean isNotNull;
    private String displayDbType;
    private String jdbcType;
    private boolean haveJdbcType;
    private static Map<String, String> typeMap;
    
    public ColumnModel() {
        this.columnName = "";
        this.humpColumnName = "";
        this.comment = "";
        this.colType = "";
        this.colDbType = "";
        this.isPK = false;
        this.length = 0L;
        this.precision = 0;
        this.scale = 0;
        this.autoGen = 0;
        this.isNotNull = false;
        this.displayDbType = "";
        this.haveJdbcType = false;
    }
    
    public String getColumnName() {
        return this.columnName;
    }
    
    public void setColumnName(final String columnName) {
        this.columnName = columnName;
    }
    
    public String getHumpColumnName() {
        return this.humpColumnName;
    }
    
    public void setHumpColumnName(final String humpColumnName) {
        this.humpColumnName = humpColumnName;
    }
    
    public String getComment() {
        return this.comment;
    }
    
    public void setComment(final String comment) {
        this.comment = comment;
    }
    
    public String getColType() {
        return this.colType;
    }
    
    public void setColType(final String colType) {
        this.colType = colType;
        this.jdbcType = ColumnModel.typeMap.get(colType);
        if (StringUtils.isNotEmpty(this.jdbcType)) {
            this.haveJdbcType = true;
        }
    }
    
    public String getColDbType() {
        return this.colDbType;
    }
    
    public void setColDbType(final String colDbType) {
        this.colDbType = colDbType;
    }
    
    public boolean getIsPK() {
        return this.isPK;
    }
    
    public void setIsPK(final boolean isPK) {
        this.isPK = isPK;
    }
    
    public long getLength() {
        return this.length;
    }
    
    public void setLength(final long length) {
        this.length = length;
    }
    
    public int getPrecision() {
        return this.precision;
    }
    
    public void setPrecision(final int precision) {
        this.precision = precision;
    }
    
    public int getScale() {
        return this.scale;
    }
    
    public void setScale(final int scale) {
        this.scale = scale;
    }
    
    public int getAutoGen() {
        return this.autoGen;
    }
    
    public void setAutoGen(final int autoGen) {
        this.autoGen = autoGen;
    }
    
    public boolean getIsNotNull() {
        return this.isNotNull;
    }
    
    public void setIsNotNull(final boolean isNotNull) {
        this.isNotNull = isNotNull;
    }
    
    public String getDisplayDbType() {
        return this.displayDbType;
    }
    
    public void setDisplayDbType(final String displayDbType) {
        this.displayDbType = displayDbType;
    }
    
    public String getJdbcType() {
        return this.jdbcType;
    }
    
    public void setJdbcType(final String jdbcType) {
        this.jdbcType = jdbcType;
    }
    
    public boolean isHaveJdbcType() {
        return this.haveJdbcType;
    }
    
    public void setHaveJdbcType(final boolean haveJdbcType) {
        this.haveJdbcType = haveJdbcType;
    }
    
    @Override
    public String toString() {
        return "ColumnModel [columnName=" + this.columnName + ", comment=" + this.comment + ", colType=" + this.colType + ", colDbType=" + this.colDbType + ", isPK=" + this.isPK + ", length=" + this.length + ", precision=" + this.precision + ", scale=" + this.scale + ", autoGen=" + this.autoGen + ", isNotNull=" + this.isNotNull + ", displayDbType=" + this.displayDbType + ", jdbcType=" + this.jdbcType + ", haveJdbcType=" + this.haveJdbcType + "]";
    }
    
    static {
        (ColumnModel.typeMap = new ConcurrentHashMap<String, String>()).put("java.lang.String", "VARCHAR");
        ColumnModel.typeMap.put("String", "VARCHAR");
        ColumnModel.typeMap.put("java.math.BigDecimal", "DECIMAL");
        ColumnModel.typeMap.put("BigDecimal", "DECIMAL");
        ColumnModel.typeMap.put("Boolean", "BOOLEAN");
        ColumnModel.typeMap.put("boolean", "BOOLEAN");
        ColumnModel.typeMap.put("byte", "TINYINT");
        ColumnModel.typeMap.put("Byte", "TINYINT");
        ColumnModel.typeMap.put("short", "SMALLINT");
        ColumnModel.typeMap.put("Short", "SMALLINT");
        ColumnModel.typeMap.put("int", "INTEGER");
        ColumnModel.typeMap.put("Integer", "INTEGER");
        ColumnModel.typeMap.put("long", "BIGINT");
        ColumnModel.typeMap.put("Long", "BIGINT");
        ColumnModel.typeMap.put("float", "REAL");
        ColumnModel.typeMap.put("Float", "REAL");
        ColumnModel.typeMap.put("double", "FLOAT");
        ColumnModel.typeMap.put("Double", "FLOAT");
        ColumnModel.typeMap.put("byte[]", "VARBINARY");
        ColumnModel.typeMap.put("java.util.Date", "TIMESTAMP");
        ColumnModel.typeMap.put("java.sql.Date", "TIMESTAMP");
        ColumnModel.typeMap.put("java.sql.Time", "TIME");
        ColumnModel.typeMap.put("java.sql.Timestamp", "TIMESTAMP");
        ColumnModel.typeMap.put("Clob", "CLOB");
        ColumnModel.typeMap.put("Blob", "BLOB");
        ColumnModel.typeMap.put("Array", "ARRAY");
    }
}
